<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
    <%@ page import="cn.edu.cqupt.cxcy.dto.TeamImpl" %>
	<%@ page import="cn.edu.cqupt.cxcy.model.*" %>
<%
    String basepath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + request.getContextPath() + "/";
%>
<style type="text/css">
.ds{
    width: 690px;
}
.ds>.member_box>div{
    width: 200px;
    height: 110px;
    margin-right: 25px;
    margin-bottom: 20px;
    float: left;
    background: #b2d771;
    padding-top: 5px;
}
.ds>div{
  	margin-top: 10px;
    float: left;
}
.ds .ds_left{
    width: 70px;
    height: 80px;
    margin-right: 8px;
    float: left;
    padding:5px 5px 0px 5px;
}
.ds .ds_left img{
    width: 60px;
    height: 60px;
    border-radius: 5px;
}
.ds .ds_right{
    padding: 0px 6px;
    height: 80px;
    font-size: 13px;
}
.ds .ds_right p{
    text-align:left;
    line-height: 20px;
}
.ds .ds_right .remove{
    border-radius: 15px;
    background: red;
    color: #fff;
    float: right;
    cursor:pointer;
}
.ds .ds_bottom>button{
    font-size: 12px;
    padding: 2px 5px;
    border:none;
    border-radius: 5px;
    background: #c3c3c5;
    float: right;
    margin-right: 10px;
}
.ds .tjds{
    width: 200px;
    height: 110px;
    cursor: pointer;
    background: #c3c3c5;
    box-shadow:3px 3px 3px #888;
    padding: 25px 0px 0px 30px;
}
.ds .tjds img,span{
    float: left;
}

.ds .tjds span{
    line-height: 50px;
    margin-left: 30px;
}
.xx{
    margin: 10px;
    background: #fafafa;
    border: 1px solid #d8d8d9;
    border-radius: 5px;
    display: none;
    
}
.xx>div{
    float: left;
    margin-right: 5px;
}
.xx p{
    margin-bottom: 10px;
}
.jbxx p>span{
    display: inline-block;
    width: 90px;
    text-align: right;
    font-size: 16px;
    font-weight: bold;
    padding-right: 10px;
}
.jbxx p{
    display: inline-block;
}
.jbxx p input{
	width:130px;
}
.xx .jj{
    margin-left: 5px;
}
.xx .jj textarea{
    width: 552px;
    height: 100px;
    resize:none;
    margin-left:10px;
    overflow-y:scroll;
}
.xx .jj>p>span{
    width: 65px;
    text-align:right;
}
.photo_head{
    float: left;
    margin-left: 20px;
}
.photo_head>input{
    width: 60px !important;
}
.button>input{
    width: 80px;
    height: 30px;
    border: 1px solid #ccc;
    background-color:#b2d771;
    border-radius: 5px;
}
.button{
    text-align:center;
}
.team_info{
    width: 650px;
    padding: 10px;
    background-color:#efefef;
}
.team_info>textarea{
    width: 415px;
    height: 100px;
}
.team_logo{
    padding: 10px;
    float: left;
    text-align: center;
    margin-right: 15px;
}
.team_logo>img{
    margin-bottom:10px;
}
.team_logo>p>input{
    width: 100px;
}
.team_info>input{
    border: 1px solid #ccc;
    margin:10px 100px;
    width: 80px;
    height: 30px;
    border-radius: 5px;
    background-color:#90c624;
}
.team_info>h2{
    padding-left: 15px;
}

</style>
<div class="xx">
<form action="./team/addmember" method="post" enctype="multipart/form-data">
    <div class="jbxx">
        <p class="photo_head">
         <img src="img/tutor1.png" width="80px" height="80px"> 
                 <input type="file" name="member_logo">
        </p>
        <p>
            <span>姓名</span><input type="text" name="member_name">
        </p>
        <p>
            <span>性别</span><input type="text" name="member_sex">
        </p>
        <p>
            <span>邮箱</span><input type="text" name="member_email">
        </p>
        <p>
            <span>电话</span><input type="text" name="member_telephone">
        </p>   
        <p>
            <span>学校</span><input type="text" name="member_school">
        </p>
         <p>
            <span>身份证号</span><input type="text" name="member_number">
        </p>
        <p>
            <span>专业</span><input type="text" name="member_college">
        </p>
        <p>
            <span>职务</span><input type="text" name="member_type">
        </p>
         <p style="display:none" >
            <span>ID</span><input type="text" name="member_id" value="0"> 
        </p>
    <div class="jj">
        <p>
            <span>简介</span>
            <textarea name="member_explain"></textarea>
        </p>
    </div>
    <div class="button">
       <input type="submit" value="提交" name="submit"> <input id="cancel_Add" type="button" value="取消">
    </div>
  </form>
</div>
</div>
<div class="ds clearfix yjds">
<%Team team = new Team();
   String serverPath = "";
   if(session.getAttribute("serverPath") != null){
	   serverPath = (String)session.getAttribute("serverPath");
   }
   if((Team)request.getAttribute("team") != null){
	team = (Team)request.getAttribute("team");
   }
    String teamName = team.getTe_name() == null ? "":team.getTe_name();
    String teamLogo = team.getTe_logo() == null ? "":team.getTe_logo();
    String teamExplain = team.getTe_explain() == null ? "":team.getTe_explain(); %>
<%
int sum_count = 0;//团队的成员总数
int sum_pages = 1;//总的分页数
int current_page = 1;//分页的当前页码数
List<Object> members = null;//团队成员的信息
if(request.getAttribute("count") != null){
	sum_count = Integer.parseInt(String.valueOf(request.getAttribute("count")));
    if(sum_count % 10 == 0){
    	sum_pages = sum_count/10;
    }else{
    	sum_pages = sum_count/10+1;
    }
}
if(request.getAttribute("members") != null){
	members = (List<Object>)request.getAttribute("members");
}%>
	
    <div class="member_box">
        <%-- <c:forEach items="${requestScope.tutors }" var="tutor"> --%>
        <%
						if(members != null){
						for(int i = 0;i<members.size();i+=2){
							int id = i/2+1;
							Member member = (Member)members.get(i);
							Teamunite teamunite = (Teamunite)members.get(i+1);
							String cTime = "";
							if(member.getM_ctime() != null){
								cTime = member.getM_ctime().toString();
							}
						%>
        <div title="<%=member.getM_id() %>">
            <div class="ds_left">
                <img src="<%=member.getM_logo() %>">
            </div>
            <div class="ds_right">
            
                 <span class="remove">一</span>
                <p>
                    姓名:<%=member.getM_name() %>
                </p>
                <p>
                    性别:<%=member.getM_sex() %>
                </p>
                <p>
                   职务:<%=teamunite.getTun_type() %>
                </p>
                <p>
                    邮箱:<%=member.getM_email() %>
                </p>   
                <p>
                    
                </p>
            </div>
            <div class="ds_bottom">
                <button>查看更多</button>
            </div>
        </div>
        <%}} %>
        <%-- </c:forEach> --%>
    </div>
    <div class="tjds">
        <img src="img/tjds.png"><span>添加成员</span>
    </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
    $(".tjds").click(function(){
            $(".xx").slideToggle();
        });
})
$(".ds_bottom>button").click(function(){
	var member_id = $(this).parent().parent().attr("title");
	$(".xx").slideDown();
	mem_info("./team/memberinfobyid",member_id);
})
$(".remove").click(function(){
	var member_id = $(this).parent().parent().attr("title");
    var that=$(this);
    mem_info("./team/memberdelete",member_id,that);
})
$("#cancel_Add").click(function(){
	$(".xx").slideUp();
})
 function print_info(el,id){
	$(".jbxx").children().eq(0).children().eq(0).attr("src",el.m_logo);
	$(".jbxx").children().eq(1).children().eq(1).val(el.m_name);
	$(".jbxx").children().eq(2).children().eq(1).val(el.m_sex);
	$(".jbxx").children().eq(3).children().eq(1).val(el.m_email);
	$(".jbxx").children().eq(4).children().eq(1).val(el.m_tel);
	$(".jbxx").children().eq(5).children().eq(1).val(el.m_school);
	$(".jbxx").children().eq(6).children().eq(1).val(el.m_no);
	$(".jbxx").children().eq(7).children().eq(1).val(el.m_college);
	$(".jbxx").children().eq(8).children().eq(1).val(el.m_type);
    $(".jbxx").children().eq(9).children().eq(1).val(id);
	$(".jj").children().children().eq(1).text(el.m_explain);
	
}
function callback(data,id,that){
  	if(data.response){
   		print_info(data,id);
    	 }
     else if(!data.response && data.mem_delete){
    	 	alert("删除成功！")
     		that.parent().parent().css("display","none");
      }else{
    	  alert("删除失败！")
      }
}

function mem_info(mem_url,id,that) {
      $.ajax({
         type: "post",
         url: mem_url,
         data: {"id":id},
         dataType: "json",
         success:function(data){
             callback(data,id,that);
         },
         error: function (e) {
             alert(e.message)
         }
     }); 

    // ---------------------下面是测试，注释即可，上面注释的ajax调用已写好，解除注释即可，目前我获取不到你返回的json； 
    //------------------测试--------------                                 
   /*  var data=
    {
       		"m_school"         : 1,
            "m_name"           : 9,
            "m_tel"       : 239,
            "m_no"        : 78,
            "response":	true,
            "mem_delete": false
    } */
    // callback(data,id,e);
    //-----------------测试--------------------
}
</script>